package cn.edu.tju.wallet.dto;

import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * VIP等级数据传输对象
 * 用于前端与后端之间的数据传输
 */
public class VipLevelDTO {

    private Long id;  // ID

    private String name;  // VIP等级名称

    private Integer level;  // VIP等级数值

    private BigDecimal minTotalConsumption;  // 最低累计消费金额

    private BigDecimal minTotalRecharge;  // 最低累计充值金额

    private BigDecimal overdraftMultiplier;  // 透支限额倍数

    private BigDecimal interestDiscount;  // 利息折扣

    private String status;  // 状态（ACTIVE/INACTIVE）

    private Integer priority;  // 优先级

    private LocalDateTime createTime;  // 创建时间

    private LocalDateTime updateTime;  // 更新时间

    // 构造函数
    public VipLevelDTO() {}

    // Getter and Setter
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getLevel() {
        return level;
    }

    public void setLevel(Integer level) {
        this.level = level;
    }

    public BigDecimal getMinTotalConsumption() {
        return minTotalConsumption;
    }

    public void setMinTotalConsumption(BigDecimal minTotalConsumption) {
        this.minTotalConsumption = minTotalConsumption;
    }

    public BigDecimal getMinTotalRecharge() {
        return minTotalRecharge;
    }

    public void setMinTotalRecharge(BigDecimal minTotalRecharge) {
        this.minTotalRecharge = minTotalRecharge;
    }

    public BigDecimal getOverdraftMultiplier() {
        return overdraftMultiplier;
    }

    public void setOverdraftMultiplier(BigDecimal overdraftMultiplier) {
        this.overdraftMultiplier = overdraftMultiplier;
    }

    public BigDecimal getInterestDiscount() {
        return interestDiscount;
    }

    public void setInterestDiscount(BigDecimal interestDiscount) {
        this.interestDiscount = interestDiscount;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public Integer getPriority() {
        return priority;
    }

    public void setPriority(Integer priority) {
        this.priority = priority;
    }

    public LocalDateTime getCreateTime() {
        return createTime;
    }

    public void setCreateTime(LocalDateTime createTime) {
        this.createTime = createTime;
    }

    public LocalDateTime getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(LocalDateTime updateTime) {
        this.updateTime = updateTime;
    }

    /**
     * 获取特权描述
     * @return 特权描述字符串
     */
    public String getPrivilegesDescription() {
        if (overdraftMultiplier == null || interestDiscount == null) {
            return "";
        }
        StringBuilder sb = new StringBuilder();
        sb.append("透支限额×").append(overdraftMultiplier);
        sb.append("，利息").append(interestDiscount.multiply(BigDecimal.valueOf(100))).append("%");
        return sb.toString();
    }

    /**
     * 获取升级条件描述
     * @return 升级条件描述字符串
     */
    public String getUpgradeConditionDescription() {
        StringBuilder sb = new StringBuilder();
        if (minTotalConsumption != null) {
            sb.append("累计消费满").append(minTotalConsumption).append("元，");
        }
        if (minTotalRecharge != null) {
            sb.append("累计充值满").append(minTotalRecharge).append("元");
        }
        return sb.toString();
    }

    @Override
    public String toString() {
        return "VipLevelDTO{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", level=" + level +
                ", status='" + status + '\'' +
                '}';
    }
}
